<template>
  <div class="box">
    <header class="header">
      <van-nav-bar
        title="个人中心"
      />
    </header>
    <div class="content" style="display: flex; justify-content: center;">
      <van-button @click="changeLogin" type="primary">{{ isLogin }}</van-button>
    </div>
  </div>
</template>

<script>
import Vue from 'vue'
import {
  NavBar,
  Button
} from 'vant'

Vue.use(NavBar)
Vue.use(Button)

export default {
  data () {
    return {
      isLogin: localStorage.getItem('isLogin') !== 'true' ? '登录' : '退出'
    }
  },
  methods: {
    changeLogin () {
      if (localStorage.getItem('isLogin') !== 'true') {
        this.$router.push('/login')
      } else {
        localStorage.removeItem('userid')
        localStorage.removeItem('token')
        localStorage.removeItem('isLogin')
        this.isLogin = '登录'
      }
    }
  }
}
</script>

<style lang="stylus"></style>
